//
//  LRJ_AsyncLayer.m
//  FBSnapshotTestCase
//
//  Created by imac_LRJ on 2022/5/31.
//

#import "LRJ_AsyncLayer.h"

@implementation LRJ_AsyncLayer

- (void)increaseDrawingCount
{
    _drawingCount = (_drawingCount + 1) % 10000;
}

- (void)setNeedsDisplay
{
    [self increaseDrawingCount];
    [super setNeedsDisplay];
}

- (void)setNeedsDisplayInRect:(CGRect)r
{
    [self increaseDrawingCount];
    [super setNeedsDisplayInRect:r];
}
- (BOOL)isAsyncDrawsCurrentContent
{
    switch (_drawingPolicy)
    {
        case LRJViewDrawingPolicyAsynchronouslyDrawWhenContentsChanged:
            return _contentsChangedAfterLastAsyncDrawing;
        case LRJViewDrawingPolicyAsynchronouslyDraw:
            return YES;
        case LRJViewDrawingPolicySynchronouslyDraw:
        default:
            return NO;
    }
}

///Discussion
//
//Do not call this method directly. The layer calls this method at appropriate times to update the layer’s content. If the layer has a delegate object, this method attempts to call the delegate’s displayLayer: method, which the delegate can use to update the layer’s contents. If the delegate does not implement the displayLayer: method, this method creates a backing store and calls the layer’s drawInContext: method to fill that backing store with content. The new backing store replaces the previous contents of the layer.
//Subclasses can override this method and use it to set the layer’s contents property directly. You might do this if your custom layer subclass handles layer updates differently.

//- (void)display
//{
//
//}


@end
